package hrms.controller;

import hrms.service.WsServiceImpl;
import hrms.util.LogUtil;
import hrms.util.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Aikes on 2017-12-22.
 */
@Controller
@RequestMapping("/ws")
public class WebServiceController
{
	@Resource(name="wsService")
	private WsServiceImpl WsServiceImpl;

	@ExceptionHandler
	public String exHandle(Exception ex, HttpServletRequest req) {
		LogUtil.saveEx(ex);
		return "error";
	}

	@ResponseBody
	@RequestMapping("/queryWeather.sls")
	public Result<List<String>> executeA(HttpServletRequest req ,HttpServletResponse res){
		String cityName = req.getParameter("cityName");
		return WsServiceImpl.queryWeather(cityName);
	}

	@ResponseBody
	@RequestMapping("/queryPhone.sls")
	public Result<String> executeB(HttpServletRequest req ,HttpServletResponse res){
		String phoneNum = req.getParameter("phoneNum");
		return WsServiceImpl.queryPhone(phoneNum);
	}
	
}
